/***************************************************************************
 *   Copyright (C) 2009 by Dead_Body                                       *
 *   jamesholodnak@gmail.com                                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef __pce_h__
#define __pce_h__

#define INPUT_A		0x01
#define INPUT_B		0x02
#define INPUT_SELECT	0x04
#define INPUT_START	0x08
#define INPUT_UP		0x10
#define INPUT_DOWN	0x20
#define INPUT_LEFT	0x40
#define INPUT_RIGHT	0x80

#include "defines.h"
#include "pce/rom.h"
#include "pce/cpu/hu6280.h"
#include "pce/vdc.h"
#include "pce/vce.h"
#include "pce/psg.h"

typedef struct sprite_s {
	u8 y,x,tile,attrib;
} sprite_t;

typedef struct pce_s	{
	u8		ram[0x2000];				//system ram (8kb)
	u8		sgram[0x8000];				//supergrafx system ram (32kb)

	int		scanline;					//current scanline
	u64		cycles;						//cycle counter
	u64		frames;						//frame counter
	u8		countrybit;					//country bit read from $1000
	u8		joydata;					//eight bit joypad data
	u8		joyselect;					//joypad nibble select (a shift amount)
	u8		irqmask,irqstatus;			//irq information
	u16		timerpreload,timervalue;	//timer
	u16		timerenable,timerstatus;	//timer

	hu6280_t		cpu;					//cpu data
	rom_t			*rom;					//pointer to current rom (created by pce_load)

	vdc_t			vdc;					//vdc data
	vce_t			vce;					//vce data
	psg_t			psg;					//psg data
} pce_t;

extern pce_t *pce;

void pce_init();						//create pce object
void pce_kill();						//destroy pce object
int pce_load(rom_t *r);				//load pce rom/cd into emulator
void pce_unload();					//unload pce rom/cd
void pce_reset(int hard);			//reset pce
int pce_frame();						//process one frame

#endif
 
